//
//  searchdetailViewController.m
//  HealthA段
//
//  Created by dllo on 15/6/16.
//  Copyright (c) 2015年 www.lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "searchdetailViewController.h"
#import "AFHTTPRequestOperationManager.h"
#import "Base.h"
#import "UIImageView+WebCache.h"
#import "Singleton.h"
#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height
@interface searchdetailViewController ()<UIWebViewDelegate>
@property(nonatomic,retain)UIWebView *Mywebview;
@property(nonatomic,retain)NSMutableArray *arr;
@property(nonatomic,retain)Base *basesourec;
@property(nonatomic,retain)UIWebView *myView;
@property(nonatomic,retain)UIImageView *myImage;
@end

@implementation searchdetailViewController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.arr = [NSMutableArray array];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [[Singleton shareSingleton] hiddenNO];
    [self data];
    [self creatWebView];
    
}

- (void)creatWebView
{
    self.myView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT - 64 - 49)];
    self.myView.delegate = self;
    self.myView.backgroundColor = [UIColor whiteColor];
    self.myView.scrollView.contentInset = UIEdgeInsetsMake(290, 0, 0, 10);
    self.myView.scrollView.backgroundColor = [UIColor whiteColor];
    self.myImage  = [[UIImageView alloc]initWithFrame:CGRectMake(0, -290, WIDTH, 290)];
    self.myImage.backgroundColor = [UIColor whiteColor];
    self.myView.scrollView.pagingEnabled = YES;
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.translucent = NO;
    [self.view sendSubviewToBack:self.myView];
    [self.view addSubview:self.myView];
    [_myView release];
}

- (void)data
{
    NSString *url = [NSString stringWithFormat:@"http://api.yi18.net/%@/show?id=%ld",self.mytype,self.myid];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager GET:url parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSMutableDictionary *dic = responseObject;
        NSMutableDictionary *DIC = dic[@"yi18"];
        Base *base = [[Base alloc] init];
        [base setValuesForKeysWithDictionary:DIC];
        [self.arr addObject:base];
        self.basesourec = base;
        NSString *str = [NSString stringWithFormat:@"http://www.yi18.net/%@",base.img];
        NSURL *url = [NSURL URLWithString:str];
        [self.myImage sd_setImageWithURL:url];
        [self.myView loadHTMLString:self.basesourec.message baseURL:nil];
        [self.myView.scrollView addSubview:self.myImage];
        if (self.arr.count > 0) {
            [[Singleton shareSingleton] hiddenYes];
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"数据请求失败");
    }];
}










- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
